package com.bruce.rentHouse.controller;

import com.bruce.rentHouse.entity.TUser;
import com.bruce.rentHouse.restFul.ResultEntity;
import com.bruce.rentHouse.restFul.ResultManger;
import com.bruce.rentHouse.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by bruce on 18/8/14 -- 14:39
 */
@Api("用户相关的api")
@RestController
@RequestMapping(value = "/users")
public class UserController {
    @Autowired
    private UserService userService;

    @ApiOperation(value = "获取所有用户列表")
    @RequestMapping(value = {"/getAll"}, method = RequestMethod.GET)
    @ApiImplicitParams({@ApiImplicitParam(paramType = "query", dataType = "String", name = "token", value = "用户id", required = true)})
    public ResultEntity getUserList(String token) {
        List<TUser> list = userService.getAllUser(token);
        return ResultManger.success(list);
    }

    @ApiOperation(value = "获取所有用户列表")
    @RequestMapping(value = {"/add"}, method = RequestMethod.GET)
    @ApiImplicitParams({@ApiImplicitParam(paramType = "query", dataType = "String", name = "token", value = "用户id", required = true)})
    public ResultEntity add(String token) {
        List<TUser> list = userService.getAllUser(token);
        return ResultManger.success(list);
    }

    @ApiOperation(value = "获取所有用户列表")
    @RequestMapping(value = {"/delete"}, method = RequestMethod.GET)
    @ApiImplicitParams({@ApiImplicitParam(paramType = "query", dataType = "String", name = "token", value = "用户id", required = true)})
    public ResultEntity delete(String token) {
        List<TUser> list = userService.getAllUser(token);
        return ResultManger.success(list);
    }

    @ApiOperation(value = "获取所有用户列表")
    @RequestMapping(value = {"/update"}, method = RequestMethod.GET)
    @ApiImplicitParams({@ApiImplicitParam(paramType = "query", dataType = "String", name = "token", value = "用户id", required = true)})
    public ResultEntity update(String token) {
        List<TUser> list = userService.getAllUser(token);
        return ResultManger.success(list);
    }

    @ApiOperation(value = "获取所有用户列表")
    @RequestMapping(value = {"/get"}, method = RequestMethod.GET)
    @ApiImplicitParams({@ApiImplicitParam(paramType = "query", dataType = "String", name = "token", value = "用户id", required = true)})
    public ResultEntity get(String token) {
        List<TUser> list = userService.getAllUser(token);
        return ResultManger.success(list);
    }
}
